[C#] LINQ Group By


In some scenarios, we would like to select each first one row
of the group which we group by personId.

The following code block is a simple example.

var memberList =
    memberSourceData.GroupBy(item => item.personId)
        .Select(chunck => chunck
            .OrderByDescending(c => c.Id)
            .First())
        .ToList();
#C#






你可能感興趣的文章

JavaScript:需要知道的部分

JavaScript:需要知道的部分

Explore-Binary Search Tree

Explore-Binary Search Tree

[重新理解 C++] 開篇

[重新理解 C++] 開篇






留言討論